package com.studykun.client.util;

import java.util.ArrayList;

public class ObservableHandlers<T> implements Observable<T> {
  private ArrayList<ObservableHandler<T>> handlers_ =
    new ArrayList<ObservableHandler<T>>();
  
  public void addObservableHandler(
      final ObservableHandler<T> handler) {
    handlers_.add(handler);
  }

  public void removeObservableHandler(
      final ObservableHandler<T> handler) {
    handlers_.remove(handler);
  }

  public void firePropertyChanged(
      final T object,
      final String propertyName,
      final Object oldValue,
      final Object newValue) {
    for (final ObservableHandler<T> handler : handlers_) {
      handler.onPropertyChanged(object, propertyName, oldValue, newValue);
    }
  }
}
